﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace ArgusPCLib.Bird
{
	public interface ILogWriter : IDisposable
	{
		bool IsDisposed { get; }
		void LogMethodEnter(string callerName, string callerFilePath, int callerLineNumber, MethodInfo methodInfo, object[] arguments);
		void LogMethodLeave(string callerName, string callerFilePath, int callerLineNumber, MethodInfo methodInfo, object[] returnValues);
		void LogMethodEnter(string callerName, string callerFilePath, int callerLineNumber, Delegate methodHandle, object[] arguments);
		void LogMethodLeave(string callerName, string callerFilePath, int callerLineNumber, Delegate methodHandle, object[] returnValues);
		void LogMessage(string callerName, string callerFilePath, int callerLineNumber, string message);
		void LogExceptionThrown(string callerName, string callerFilePath, int callerLineNumber, ExceptionWrapper exception);
	}

	public abstract class LogWriter : ILogWriter
	{
		public abstract bool IsDisposed { get; }
		public abstract void LogMethodEnter(string callerName, string callerFilePath, int callerLineNumber, MethodInfo methodInfo, object[] arguments);
		public abstract void LogMethodLeave(string callerName, string callerFilePath, int callerLineNumber, MethodInfo methodInfo, object[] returnValues);
		public virtual void LogMethodEnter(string callerName, string callerFilePath, int callerLineNumber, Delegate methodHandle, object[] arguments)
		{
			this.LogMethodEnter(callerName, callerFilePath, callerLineNumber, methodHandle.GetMethodInfo(), arguments);
		}
		public virtual void LogMethodLeave(string callerName, string callerFilePath, int callerLineNumber, Delegate methodHandle, object[] returnValues)
		{
			this.LogMethodLeave(callerName, callerFilePath, callerLineNumber, methodHandle.GetMethodInfo(), returnValues);
		}
		public abstract void LogMessage(string callerName, string callerFilePath, int callerLineNumber, string message);
		public abstract void LogExceptionThrown(string callerName, string callerFilePath, int callerLineNumber, ExceptionWrapper exception);
		public abstract void Dispose();
	}
}